<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<script type="text/javascript">
	var ctx="${pageContext.request.contextPath}";
</script>
<style>
	.header-bar-container.fixed {
	  background-color: #2f2f2f;
	  left: 0;
	  position: fixed;
	  height: 50px;
	  padding: 0;
	  z-index: 999;
	}
	
	
</style>
    
<script type="text/javascript">
	function checkData(){
		var q=document.getElementById("q").value.trim();
		if(q==null || q==""){
			alert("请输入您要查询的博客关键字！");
			return false;
		}else{
			return true;
		}
	}
	
	function navbarActive(){
		var ctxLength=ctx.length;
		$(".navbar-nav").find("li").each(function () {
            var a = $(this).find("a:first")[0];
            if ($(a).attr("href").substring(ctxLength) === location.pathname.substring(ctxLength)) {
                $(this).addClass("active");
            } else {
                $(this).removeClass("active");
            }
        });
	}
	
	function torbarToTop(){
		var topbar = $('.header-bar-container');
        //fixed navigation bar to top --PC
        if (topbar.is('*')) {
          var elem = $('.container');
          var offset = elem.offset();
          var leftValue = offset.left;
          var topValue = offset.top;
          var width = elem.width();
          var topbarHeight = topbar.height();
          var stickyDiv = '<div class="sticky-placeholder" style="height:' + topbarHeight + 'px"></div>';
          $(window).scroll(function (event) {
            var y = $(this).scrollTop();
            if (y >= topValue) {
              if (topbar.hasClass('fixed')) {
            	  
              } else {
	              topbar.addClass('fixed').addClass('sticky');
	               $('#page header').prepend(stickyDiv);
	              topbar.css({
	                  top: '-' + topbarHeight + 'px',
	                  width: '100%',
	              });
	              topbar.animate({
	                  top: 0
	              }, 1000, function () {
	            	  
	              });
              }
            } else {
              if (topbar.hasClass('sticky')) {
                topbar.removeClass('sticky');
                topbar.animate({
                	  top: 0,
	                }, 0, function () {
	                  topbar.removeClass('fixed');
                });
              }
            }
          });
        }
	}
	
	$(function () {
		navbarActive();
        
		torbarToTop();
    });
</script>
<div class="row">
	<div class="col-md-12 header-bar-container">
		<nav class="navbar navbar-inverse my-navbar">
		  <div class="container-fluid">
		    <!-- Brand and toggle get grouped for better mobile display -->
		    <div class="navbar-header">
		      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
		        <span class="sr-only">Toggle navigation</span>
		        <span class="icon-bar"></span>
		        <span class="icon-bar"></span>
		        <span class="icon-bar"></span>
		      </button>
		      <a class="navbar-brand" href="${pageContext.request.contextPath}/index/new.html"><font color="white"><strong>LiddBlog</strong></font></a>
		      
		    </div>

		    <!-- Collect the nav links, forms, and other content for toggling -->
		    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1" >
		      <ul class="nav navbar-nav">
		        <!-- <li><a href="${pageContext.request.contextPath}/download.html"><font color="black"><strong>本站源码下载</strong></font></a></li> -->
		        <li><a href="${pageContext.request.contextPath}/lifethings.html"><strong>生活琐事</strong></a></li>
		        <li><a href="${pageContext.request.contextPath}/oldtimes.html"><strong>韶华记忆</strong></a></li>
		        <li><a href="${pageContext.request.contextPath}/essay.html"><strong>心情随笔</strong></a></li>
		        <li><a href="${pageContext.request.contextPath}/quotation.html"><strong>语录收集</strong></a></li>
		        <%-- <li><a href="${pageContext.request.contextPath}/##"><strong>时光渐逝</strong></a></li> --%>
		        <li><a href="${pageContext.request.contextPath}/message.html"><strong>博客留言</strong></a></li>
		        <li><a href="${pageContext.request.contextPath}/blogger/aboutMe.html"><strong>关于博主</strong></a></li>
		      </ul>
		      <form action="${pageContext.request.contextPath}/blog/q.html" class="navbar-form navbar-right" role="search" method="post" onsubmit="return checkData()">
		        <div class="form-group" >
		          <input type="text" id="q" name="q" value="${q }" class="form-control" placeholder="请输入要查询的博客关键字...">
		        </div>
		        <button type="submit" class="btn btn-default">搜索</button>
		      </form>
		    </div><!-- /.navbar-collapse -->
		  </div><!-- /.container-fluid -->
		</nav>
	</div>
</div>